package com.unittec.zk.provider.exam.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.unittec.zk.provider.exam.entity.ElPaperQuAnswer;
import com.unittec.zk.provider.exam.utils.BeanMapper;
import com.unittec.zk.sdk.exam.domain.PaperQuDTO;
import com.unittec.zk.sdk.exam.domain.PaperQuDetailDTO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unittec.zk.provider.exam.entity.ElPaperQu;
import com.unittec.zk.provider.exam.mapper.ElPaperQuMapper;
@Service
public class ElPaperQuService extends ServiceImpl<ElPaperQuMapper, ElPaperQu> {

    public List<PaperQuDTO> listByPaper(String paperId) {
        //查询条件
        QueryWrapper<ElPaperQu> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ElPaperQu::getPaperId, paperId)
                .orderByAsc(ElPaperQu::getSort);

        List<ElPaperQu> list = this.list(wrapper);
        List<PaperQuDTO> paperQuDTOS = BeanMapper.mapList(list, PaperQuDTO.class);
        return paperQuDTOS;
    }

    public ElPaperQu findByKey(String paperId, String quId) {
        //查询条件
        QueryWrapper<ElPaperQu> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ElPaperQu::getPaperId, paperId)
                .eq(ElPaperQu::getQuId, quId);

        return this.getOne(wrapper, false);
    }

    public void updateByKey(ElPaperQu qu) {
        //查询条件
        QueryWrapper<ElPaperQu> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(ElPaperQu::getPaperId, qu.getPaperId())
                .eq(ElPaperQu::getQuId, qu.getQuId());

        this.update(qu, wrapper);
    }
}
